//
//  GTListItem.m
//  news
//
//  Copyright © 2022 sinosun. All rights reserved.
//

#import "GTListItem.h"

@interface GTListItem () <NSSecureCoding>

@end

@implementation GTListItem


- (void)configureWithDictionary:(NSDictionary *)dictionary{
    self.category = dictionary[@"category"];
    self.pictureUrl = dictionary[@"thumbnail_pic_s"];
    self.uniquekey = dictionary[@"uniquekey"];
    self.title = dictionary[@"title"];
    self.date = dictionary[@"date"];
    self.authorName = dictionary[@"author_name"];
    self.articUrl = dictionary[@"url"];
    
#warning 判断
}


#pragma mark - NSSecureCoding
// 安全相关
+ (BOOL)supportsSecureCoding
{
    return YES;
}

// 反序列化的方法
- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super init];
    if (self) {
        self.category = [coder decodeObjectForKey:@"category"];
        self.pictureUrl = [coder decodeObjectForKey:@"pictureUrl"];
        self.uniquekey = [coder decodeObjectForKey:@"uniquekey"];
        self.title = [coder decodeObjectForKey:@"title"];
        self.date = [coder decodeObjectForKey:@"date"];
        self.authorName = [coder decodeObjectForKey:@"authorName"];
        self.articUrl = [coder decodeObjectForKey:@"articUrl"];
    }
    return self;
}

// 序列化的方法
- (void)encodeWithCoder:(NSCoder *)coder
{
    [coder encodeObject:self.category forKey:@"category"];
    [coder encodeObject:self.pictureUrl forKey:@"pictureUrl"];
    [coder encodeObject:self.uniquekey forKey:@"uniquekey"];
    [coder encodeObject:self.title forKey:@"title"];
    [coder encodeObject:self.date forKey:@"date"];
    [coder encodeObject:self.authorName forKey:@"authorName"];
    [coder encodeObject:self.articUrl forKey:@"articUrl"];
    
}






@end
